package com.ld.admin.util.daliySentence;

import java.util.HashMap;

import com.ld.admin.util.daliySentence.model.DaliySentenceBaseInfo;

/**
 * 基本信息享元工厂
 * 
 * @author <a href="mailto:donggongai@126.com" target="_blank">吕凯</a>
 * @date 2020年10月28日 下午2:54:49
 *
 */
public class DaliySentenceBaseInfoFactory {
    private static final HashMap<String, DaliySentenceBaseInfo> POOL = new HashMap<>();

    // 享元工厂
    public static DaliySentenceBaseInfo getDSBaseInfo(String key) {

        DaliySentenceBaseInfo baseInfo = POOL.get(key); // 从池中获取对象
        if (baseInfo == null) {
            synchronized (POOL) {
                baseInfo = POOL.get(key);
                if (baseInfo == null) {
                    // 根据外部状态创建享元对象
                    baseInfo = new DaliySentenceBaseInfo();
                    // 放入池中
                    POOL.put(key, baseInfo);
                }
            }

        }
        return baseInfo;
    }

}
